<template>
  <div class="app-container">
    <el-table v-loading="loading"  :data="rworkList">
      <el-table-column type="index" width="55" align="center" />
       <el-table-column label="车间" align="center" prop="slWorkshop.workshopName" />
       <el-table-column label="大工序" align="center" prop="slGprocess.gprocessName" />
       <el-table-column label="小工序" align="center" prop="slProcess.processName" />
      <el-table-column label="生产鼓号" align="center" prop="wtermDnumber" />
      <el-table-column label="订单编号" align="center" prop="wtermOnumber" />
      <el-table-column label="品种" align="center" prop="breed.breedName" />
      <el-table-column label="操作人" align="center" width="180">
        <template slot-scope="scope">
          <span v-for="(item,index) in scope.row.slRworkRmemberList" :key="index">
            {{item.rmemberNick}} {{index === scope.row.slRworkRmemberList.length-1 ? "":","}}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="颜色" align="center" prop="colour.colourName" />
      <el-table-column label="工艺要求" align="center" prop="rworkTr" />
      <el-table-column label="单位" align="center" prop="rworkDw" />
      <el-table-column label="计划生产" align="center" prop="rworkPlan" />
      <el-table-column label="实际生产" align="center" prop="rworkActual" />
      <el-table-column label="工序单价" align="center" prop="processPay" />
      <el-table-column label="开始时间" align="center" prop="rworkStart" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rworkStart, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束时间" align="center" prop="rworkEnd" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rworkEnd, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="工作时长" align="center" prop="rworkDuration" />
      <el-table-column label="报工项工资" align="center" prop="estimatePay" />
 <!--     <el-table-column label="班组" align="center" prop="estimatePay" >
        <template slot-scope="scope">
          <span v-if="scope.row.slRworkRmemberList.length>0">
          <dict-tag :options="dict.type.sl_rwork_class" :value="scope.row.slRworkRmemberList[0].rmemberBz"/>
          </span>

        </template>
      </el-table-column> -->
      <el-table-column fixed="right" label="操作" width="80" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleDetail(scope.row)"
            v-hasPermi="['sl:rwork:query']"
          >详细</el-button>
        </template>
      </el-table-column>
    </el-table>

 <!--  <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    /> -->

    <!-- 详细报工单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="960px" append-to-body>
      <el-form ref="form" :model="form" label-width="80px">
       <el-row>
         <el-col :span="12" >
           <el-form-item label="生产鼓号/生产批号" label-width="140px">
             {{form.wtermDnumber}}
           </el-form-item>
         </el-col>
         <el-col :span="12">
           <el-form-item label="订单编号" >
             {{form.wtermOnumber}}
           </el-form-item>
         </el-col>
       </el-row>
       <el-row>
         <el-col :span="8">
           <el-form-item label="模块">
             {{ form.slModule != null ? form.slModule.moduleName : '' }}
           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="车间">
             {{ form.slWorkshop != null ? form.slWorkshop.workshopName : '' }}
           </el-form-item>
         </el-col>
        <el-col :span="8">
          <el-form-item label="大工序">
            {{ form.slGprocess != null ? form.slGprocess.gprocessName : '' }}
          </el-form-item>
       </el-col>
        </el-row>
        <el-row>
        <el-col :span="8">
         <el-form-item label="小工序" prop="processId">
           {{ form.slProcess != null ? form.slProcess.processName : '' }}
         </el-form-item>
        </el-col>
        <el-col :span="8">
           <el-form-item label="工序单价" prop="processPay">
             {{form.processPay}}
           </el-form-item>
        </el-col>
         <el-col :span="8">
           <el-form-item label="品种" prop="breedId">
             {{  form.breedName }}
           </el-form-item>
         </el-col>
       </el-row>
        <el-row>
          <el-col :span="8">
           <el-form-item label="颜色" prop="colourId">
             {{  form.colourName  }}
           </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工艺要求" prop="rworkTr">
              {{form.rworkTr}}
            </el-form-item>
          </el-col>
           <el-col :span="8">
                <el-form-item label="单位" prop="rworkDw">
                  {{form.rworkDw}}
                </el-form-item>
             </el-col>
        </el-row>
          <el-row>
          <el-col :span="8">
           <el-form-item label="计划生产" prop="rworkPlan">
             {{form.rworkPlan}}
          </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="实际生产" prop="rworkActual">
              {{form.rworkActual}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="重复次数" prop="rworkRepetitions">
              {{form.rworkRepetitions}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
          <el-form-item label="开始时间" prop="rworkStart">
            {{form.rworkStart}}
          </el-form-item>
          </el-col>
          <el-col :span="8">
          <el-form-item label="结束时间" prop="rworkEnd">
            {{form.rworkEnd}}
          </el-form-item>
          </el-col>
          <el-col :span="8">
           <el-form-item label="工作时长" prop="rworkDuration">
             {{form.rworkDuration}}
           </el-form-item>
          </el-col>
           </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="预估工资" prop="estimatePay">
              {{form.estimatePay}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="center">操作人</el-divider>
          <el-table :data="slRworkRmemberList" :row-class-name="rowSlRworkRmemberIndex" ref="slRworkRmember" style="width:100%">
            <el-table-column label="序号" align="center" prop="index" width="50"/>
            <el-table-column label="参与人" prop="rmemberNick"  />
            <el-table-column label="职级" prop="levelName" />
            <el-table-column label="计薪方式" prop="ssmName" />
            <el-table-column label="时长" prop="rmemberDuration" />
            <el-table-column label="班组" prop="rmemberBz" >
              <template slot-scope="scope">
                  <dict-tag :options="dict.type.sl_rwork_class" :value="scope.row.rmemberBz"/>
                </template>
            </el-table-column>
          </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="this.$store.state.user.name===form.rworkUser" type="primary" @click="handleUpdate">修改报工</el-button>
        <el-button @click="cancel">返 回</el-button>
      </div>
    </el-dialog>

    <!-- 编辑报工单对话框 -->
    <el-dialog :title="editTitle" :visible.sync="editOpen" width="960px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="生产鼓号/生产批号" label-width="140px" prop="wtermDnumber">
              <el-input v-model="form.wtermDnumber" placeholder="请输入生产鼓号/生产批号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
              <el-form-item label="订单编号"  prop="wtermOnumber">
                <el-autocomplete class="inline-input" v-model="form.wtermOnumber" :fetch-suggestions="querySearchOrder"
                  placeholder="请输入订单编号" :trigger-on-focus="false"></el-autocomplete>
              </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
           <el-form-item label="所属模块" prop="moduleId">
             <el-select v-model="form.moduleId" :disabled="true" filterable @change="handleChangeModule" placeholder="请选择所属模块">
               <el-option v-for="item in moduleOptions" :key="item.moduleId" :label="item.moduleName"
                 :value="item.moduleId" :disabled="item.status == 1"></el-option>
             </el-select>
           </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所属车间" prop="workshopId">
              <el-select v-model="form.workshopId" filterable @change="handleChangeWorkshop" placeholder="请选择所属车间">
                <el-option v-for="item in workshopOptions" :key="item.workshopId" :label="item.workshopName"
                  :value="item.workshopId" :disabled="item.status == 1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
         <el-col :span="8">
          <el-form-item label="大工序" prop="gprocessId">
            <el-select v-model="form.gprocessId" filterable @change="handleChangeProcess" placeholder="请选择大工序">
              <el-option v-for="item in gprocessOptions" :key="item.gprocessId" :label="item.gprocessName"
                :value="item.gprocessId" :disabled="item.status == 1"></el-option>
            </el-select>
          </el-form-item>
         </el-col>
         </el-row>
         <el-row>
         <el-col :span="8">
          <el-form-item label="小工序" prop="processId">
            <el-select v-model="form.processId" filterable @change="handleGetProcessPay" placeholder="请选择小工序">
              <el-option v-for="item in processOptions" :key="item.processId" :label="item.processName"
                :value="item.processId" :disabled="item.status == 1"></el-option>
            </el-select>
          </el-form-item>
         </el-col>
         <el-col :span="8">
            <el-form-item label="工序单价" prop="processPay">
              <el-input v-model="form.processPay" :disabled="true" placeholder="选择小工序后自动获取" />
            </el-form-item>
         </el-col>
          <el-col :span="8">
            <el-form-item label="品种" prop="breedId">
               <el-autocomplete class="inline-input" v-model="form.breedName" :fetch-suggestions="querySearchBreed"
                placeholder="请输入品种" :trigger-on-focus="false"></el-autocomplete>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
           <el-form-item label="颜色" prop="colourId">
            <el-autocomplete class="inline-input" v-model="form.colourName" :fetch-suggestions="querySearchColour"
               placeholder="请输入颜色" :trigger-on-focus="false"></el-autocomplete>
           </el-form-item>
          </el-col>
          <el-col :span="8">
           <el-form-item label="工艺要求" prop="rworkTr">
             <el-input v-model="form.rworkTr" placeholder="请输入工艺要求" />
           </el-form-item>
          </el-col>
           <el-col :span="8">
             <el-form-item label="单位" prop="rworkDw">
               <el-input v-model="form.rworkDw" placeholder="请输入单位" />
             </el-form-item>
          </el-col>
        </el-row>
          <el-row>
          <el-col :span="8">
           <el-form-item label="计划生产" prop="rworkPlan">
             <el-input v-model="form.rworkPlan" class="def-input-number" type="number" placeholder="请输入计划生产" />
           </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="实际生产" prop="rworkActual">
              <el-input v-model="form.rworkActual" class="def-input-number" type="number"
                placeholder="请输入实际生产" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="重复次数" prop="rworkRepetitions">
              <el-input-number v-model="form.rworkRepetitions" controls-position="right" :min="1" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
          <el-form-item label="开始时间" prop="rworkStart">
            <el-date-picker clearable style="width:100%" v-model="form.rworkStart" type="datetime"
              value-format="yyyy-MM-dd HH:mm:ss" default-time="12:00:00" placeholder="请选择开始时间"
               @change="handleCompareTime">
            </el-date-picker>
          </el-form-item>
          </el-col>
          <el-col :span="8">
          <el-form-item label="结束时间" prop="rworkEnd">
            <el-date-picker clearable style="width:100%" v-model="form.rworkEnd" type="datetime"
              value-format="yyyy-MM-dd HH:mm:ss" default-time="12:00:00" placeholder="请选择结束时间"
               @change="handleCompareTime">
            </el-date-picker>
          </el-form-item>
          </el-col>
          <el-col :span="8">
           <el-form-item label="工作时长" prop="rworkDuration">
             <el-input v-model="form.rworkDuration"  class="def-input-number" type="number" placeholder="请输入工作时长" />
           </el-form-item>
          </el-col>
           </el-row>
        <el-row>
          <el-col :span="8">
           <el-form-item label="预估工资" prop="estimatePay">
             <el-input v-model="form.estimatePay" :disabled="true" placeholder="请输入预估工资" />
           </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="center">操作人</el-divider>
      <!--  <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddSlRworkRmember">添加</el-button>
          </el-col>
          <UserMultiSelect ref="userSelect" @onSelected="userSelected"></UserMultiSelect>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini"
              @click="handleDeleteSlRworkRmember">删除</el-button>
          </el-col>
        </el-row> -->
          <el-table :data="slRworkRmemberList" :row-class-name="rowSlRworkRmemberIndex"
          @selection-change="handleSlRworkRmemberSelectionChange" ref="slRworkRmember" style="width:100%">
            <el-table-column type="selection" width="50" align="center" />
            <el-table-column label="序号" align="center" prop="index" width="50"/>
            <el-table-column label="参与人" prop="rmemberNick"  />
            <el-table-column label="职级" prop="levelName" />
            <el-table-column label="计薪方式" prop="ssmName" />
            <el-table-column label="时长" prop="rmemberDuration" >
              <template slot-scope="scope" v-if="scope.row.ssmId=='5'||scope.row.levelId=='7'||scope.row.levelId=='8'||scope.row.levelId=='9'">
                  <el-input required v-model="scope.row.rmemberDuration" class="def-input-number" type="number" placeholder="请输入时长" />
              </template>
            </el-table-column>
            <el-table-column label="班组" prop="rmemberBz" >
              <template slot-scope="scope">
                 <el-select v-model="scope.row.rmemberBz" placeholder="请选择班组" clearable>
                   <el-option
                     v-for="dict in dict.type.sl_rwork_class"
                     :key="dict.value"
                     :label="dict.label"
                     :value="dict.value"
                   />
                 </el-select>
                </template>
            </el-table-column>
          </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="this.$store.state.user.name===form.rworkUser" type="primary" @click="submitForm">重新提交审核</el-button>
        <el-button @click="cancelEdit">返 回</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRwork, getRwork, delRwork, addRwork, updateRwork,listHRwork } from "@/api/sl/rwork";
import UserMultiSelect from "@/components/userSelect/multi.vue"
import {getProcessListByGprocessId,getProcessPay} from "@/api/sl/process";
import {formatDate,formatOnlyDate} from '@/utils/index'
import {allAttendance,addAttendance,updateAttendance, updateAttendanceList} from "@/api/sl/attendance";
import {getAllOrder} from "@/api/sl/order";
import {getAllColour} from "@/api/sl/colour";
import {getAllBreed} from "@/api/sl/breed";
import {getWorkshopListByModuleId} from "@/api/sl/workshop";
import {getGprocessListByWorkshopId} from "@/api/sl/gprocess";
import {allRworkMember,allRworkMemberByRworkId} from "@/api/sl/rmember.js";

export default {
  name: "Hrwork",
  components: {UserMultiSelect},
  dicts: ['sl_rwork_class'],
  data() {
    let watermarkContentVaild=(rule, value, callback)=>{
      if(value==null || value===""){
        callback();
      }else{
        let length=value.length
        if(length>7){
          callback(new Error("输入不能超过7位"))
        }else{
          callback();
        }
      }
    }
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 报工单表格数据
      rworkList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        rfworkId: null,
        memberUser:null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
         moduleId: [
           {required: true,message: "模块不能为空",trigger: "blur"},
         ],
         workshopId: [
           {required: true,message: "车间不能为空",trigger: "blur"},
         ],
         gprocessId: [
           {required: true,message: "大工序不能为空",trigger: "blur"},
         ],
         processId: [
           {required: true,message: "小工序不能为空",trigger: "blur"},
         ],
         processPay: [
           {required: true,message: "工序单价不能为空",trigger: "blur"}
         ],
         rworkPlan: [
           {validator: watermarkContentVaild, trigger: 'blur'}
         ],
         rworkActual: [
           {validator: watermarkContentVaild, trigger: 'blur'}
         ],
         rworkDuration: [
           {validator: watermarkContentVaild, trigger: 'blur'}
         ],
         estimatePay: [
           {validator: watermarkContentVaild, trigger: 'blur'}
         ],
      },
      moduleOptions: [],
      workshopOptions: [],
      gprocessOptions: [],
      processOptions: [],
       // 操作人表格数据
      slRworkRmemberList: [],
      editTitle: "",
      editOpen: false

    };
  },
  created() {
    const rfworkId = this.$route.query && this.$route.query.rfworkId;
    if (rfworkId) {
      this.queryParams.rfworkId = rfworkId;
    }
    this.getList();
  },
  watch: {
    "form.processPay":{
      handler(newName, oldName) {
        this.handleCountPay()
      },
    },
    "form.rworkActual":{
      handler(newName, oldName) {
        this.handleCountPay()
      },
    },
    "form.rworkRepetitions":{
      handler(newName, oldName) {
        this.handleCountPay()
      },
    },
  },
  methods: {
    /** 查询报工单列表 */
    getList() {
      this.loading = true;
      listHRwork(this.queryParams).then(response => {
        this.rworkList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    cancelEdit() {
      this.editOpen = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
       rworkId: null,
       rworkDate: null,
       moduleId: null,
       workshopId: null,
       rworkBz: null,
       rworkYear: null,
       rworkMonth: null,
       rworkDay: null,
       isApproved: null,
       createBy: null,
       createTime: null,
       leaderUser: null,
       wtermDnumber: null,
       wtermOnumber: null,
       gprocessId: null,
       processId: null,
       breedName: null,
       colourName: null,
       rworkTr: null,
       rworkDw: null,
       rworkPlan: null,
       rworkActual: null,
       rworkRepetitions: 1,
       rworkStart: null,
       rworkEnd: null,
       rworkDuration: null,
       processPay: null,
       estimatePay: null,
       rworkUser: null,
       rworkDm: null,
       rfworkId: null,
       wtermBatch: null,
       actualBatch: null
      };
      this.slRworkRmemberList = [];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.$refs["queryForm"].validate(valid => {
        if (valid) {
          this.queryParams.pageNum = 1;
          this.getList();
        }
      })
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 详细按钮操作 */
    handleDetail(row) {
      this.reset();
      const rworkId = row.rworkId || this.ids
      getRwork(rworkId).then(response => {
        this.form = response.data;
        this.gprocessOptions = response.gprocesss;
        this.processOptions = response.processs;
        this.moduleOptions = response.modules;
        this.workshopOptions = response.workshops;
        this.slRworkRmemberList = response.data.slRworkRmemberList;
        this.open = true;
        this.title = "报工单详细";
      });
    },
    /** 修改报工按钮操作 */
    handleUpdate(row) {
      this.open = false;
      this.editOpen = true;
      this.editTitle = "修改报工单";
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.slRworkRmemberList = this.slRworkRmemberList;
          if (this.form.rworkId != null) {
            updateRwork(this.form).then(response => {
              this.$modal.msgSuccess("提交审核成功");
              this.editOpen = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const rworkIds = row.rworkId || this.ids;
      this.$modal.confirm('是否确认删除报工单编号为"' + rworkIds + '"的数据项？').then(function() {
        return delRwork(rworkIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('sl/rwork/export', {
        ...this.queryParams
      }, `rwork_${new Date().getTime()}.xlsx`)
    },
    	/** 操作人序号 */
    rowSlRworkRmemberIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 操作人添加按钮操作 */
    handleAddSlRworkRmember() {
      this.$refs.userSelect.showFlag = true;
      //this.slRworkRmemberList.push(obj);
    },
    /** 操作人删除按钮操作 */
    handleDeleteSlRworkRmember() {
      if (this.checkedSlRworkRmember.length == 0) {
        this.$modal.msgError("请先选择要删除的操作人数据");
      } else {
        const slRworkRmemberList = this.slRworkRmemberList;
        const checkedSlRworkRmember = this.checkedSlRworkRmember;
        this.slRworkRmemberList = slRworkRmemberList.filter(function(item) {
          return checkedSlRworkRmember.indexOf(item.index) == -1
        });
      }
    },
    /** 复选框选中数据 */
    handleSlRworkRmemberSelectionChange(selection) {
      this.checkedSlRworkRmember = selection.map(item => item.index)
    },
    //比较时间
    handleCompareTime() {
      if (this.form.rworkStart && this.form.rworkEnd) {
        let difference = new Date(this.form.rworkEnd) - new Date(this.form.rworkStart);
        this.form.rworkDuration = (difference / 3600000).toFixed(2)
      } else {
        this.form.rworkDuration = null;
      }
    },
    querySearchOrder(queryString, cb) {
      var orderNumList = this.orderNumList;
      var results = queryString ? orderNumList.filter(this.createFilter(queryString,"order")) : orderNumList;
      cb(results);
    },
    querySearchBreed(queryString, cb) {
      var breedList = this.breedList;
      var results = queryString ? breedList.filter(this.createFilter(queryString,"breed")) : breedList;
      cb(results);
    },
    querySearchColour(queryString, cb) {
      var colourList = this.colourList;
      var results = queryString ? colourList.filter(this.createFilter(queryString,"colour")) : colourList;
      cb(results);
    },
    createFilter(queryString,type) {
      if(type==="order"){
        return (order) => {
          return (order.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      }else if(type==="colour"){
        return (colour) => {
          return (colour.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      }else if(type==="breed"){
        return (breed) => {
          return (breed.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      }
    },
    handleCountPay() {
      this.form.estimatePay = Math.floor(this.form.processPay * this.form.rworkActual * this.form.rworkRepetitions * 1000) / 1000;
    },
    userSelected(rows) {
      if (rows != null) {
        rows.forEach(user => {
          let obj = {};
          obj.rmemberUser = user.userName;
          obj.rmemberNick = user.nickName;
          obj.levelId = user.levelId;
          obj.ssmId = user.ssmId;
          obj.levelName = user.level.levelName;
          obj.ssmName = user.ssm.ssmName;
          obj.isFormalworker = user.isFormalworker;
          obj.isHourlyworker = user.isHourlyworker;
          obj.rmemberBz = '3';
          if (isUniqueUser(this.slRworkRmemberList, obj)) {
            this.slRworkRmemberList.push(obj);
          }
        })
      }
    },
    //获取小工序单价
    handleGetProcessPay(value) {
      for (let i = 0; i < this.processOptions.length; i++) {
        if (this.processOptions[i].processId === value) {
          this.form.processPay = this.processOptions[i].processPay;
          break;
        }
      }
    },
    //模块变更查询车间
    handleChangeModule(value) {
      //清空车间
      this.form.workshopId = null;
      this.workshopOptions = [];
      //清空大工序
      this.form.gprocessId = null;
      this.gprocessOptions = [];
      //清空小工序
      this.form.processId = null;
      this.processOptions = [];
      //工序单价
      this.form.processPay = null;
      getWorkshopListByModuleId(value).then(response => {
        this.workshopOptions = response.data;
      });
    },
    //车间变更查询大工序
    handleChangeWorkshop(value) {
      //清空大工序
      this.form.gprocessId = null;
      this.gprocessOptions = [];
      //清空小工序
      this.form.processId = null;
      this.processOptions = [];
      //工序单价
      this.form.processPay = null;
      getGprocessListByWorkshopId(value).then(response => {
        this.gprocessOptions = response.data;
      });
    },
    //大工序变更查询小工序
    handleChangeProcess(value) {
      //清空小工序
      this.form.processId = null;
      this.processOptions = [];
      //工序单价
      this.form.processPay = null;
      getProcessListByGprocessId(value).then(response => {
        this.processOptions = response.data;
      });
    },
  },
  //挂载订单号
  mounted() {
    getAllOrder().then(response => {
      this.orderNumList = response.data.map(item => ({
        "value": item.orderNum,
      }))
    });
    getAllColour().then(response => {
      this.colourList = response.data.map(item => ({
        "value": item.colourName,
      }))
    });
    getAllBreed().then(response => {
      this.breedList = response.data.map(item => ({
        "value": item.breedName,
      }))
    });
  },
}
</script>
<style>
.el-table .el-table__body-wrapper::-webkit-scrollbar {
    height: 10px;
}
</style>


